const app = create();
const takeLatest = { type: 'takeLatest' };
app.model({
  namespace: 'count',
  state: 0,
  reducers: {
    add(state, { payload }) {
      return state + payload || 1;
    },
  },
  effects: {
    addDelay: [
      function*({ payload }, { call, put }) {
        yield call(delay, 100);
        yield put({ type: 'add', payload });
      },
      takeLatest,
    ],
  },
});
app.start();

// Only catch the last one.
app._store.dispatch({ type: 'count/addDelay', payload: 2 });
app._store.dispatch({ type: 'count/addDelay', payload: 3 });

setTimeout(() => {
  expect(app._store.getState().count).toEqual(3);
}, 200);

